package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseBaseApi;
import com.xuecheng.api.content.model.qo.QueryCourseModel;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.service.CourseBaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 课程基本信息 前端控制器
 * </p>
 *
 * @author itcast
 */
@Slf4j
@RestController
public class CourseBaseController implements CourseBaseApi {

    @Autowired
    private CourseBaseService  courseBaseService;

    /**
     * springMVC默认情况下封装参数使用queryString：@RequestParam
     *      如果参数是json格式，参数前加@RequestBody
     * @param params
     * @param model
     * @return
     */
    @PostMapping("course/list")
    public PageVO queryCourseList(PageRequestParams params,@RequestBody QueryCourseModel model) {
        //通过工具类获得公司id
        Long companyId = SecurityUtil.getCompanyId();
        PageVO pageVO = courseBaseService.queryCourseList(params,model,companyId);
        return pageVO;
    }
}
